package com.ebolib.base;

import android.content.Intent;
import android.os.Build;
import android.support.v4.app.ActivityCompat;

import com.ebo.corelib.ui.BaseFragment;
import com.ebo.corelib.ui.mvp.BasePresenter;
import com.ebo.corelib.utils.AnimeUtils;
import com.ebolib.net.OutDateEvent;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;



/**
 * Created by admin on 2018/5/17.
 */

public abstract class MyBaseFragment<P extends BasePresenter> extends BaseFragment<P> {


    @Override
    public void startActivity(Intent intent) {
        if (Build.VERSION.SDK_INT < 16) {
            super.startActivity(intent);
        } else {
            ActivityCompat.startActivity(getContext(), intent, AnimeUtils.sceneTransAnime(getContext()));
        }
    }

    @Override
    public void startActivityForResult(Intent intent, int requestCode) {
        if (Build.VERSION.SDK_INT < 16) {
            super.startActivityForResult(intent, requestCode);
        } else {
            ActivityCompat.startActivityForResult(getActivity(), intent, requestCode, AnimeUtils.sceneTransAnime(getContext()));
        }
    }


    @Override
    public void onResume() {
        super.onResume();
        EventBus.getDefault().register(this);
    }

    @Override
    public void onPause() {
        super.onPause();
        EventBus.getDefault().unregister(this);
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onOutDate(OutDateEvent event) {
        onOutDatePreExcuted();

    }

    protected void onOutDatePreExcuted() {

    }
}
